<template>
    <div>
        <div style="margin-top: 15px;display: flex;justify-content: space-between;">
            <el-form :inline="true" :model="forObject" class="demo-form-inline" >
                <el-form-item>
                    <el-input v-model="forObject.name" placeholder="姓名"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" @click="page">查询</el-button>
                    <el-button type="primary" icon="el-icon-bottom">高级搜索</el-button>
                </el-form-item>
            </el-form>

            <el-form :inline="true"  class="demo-form-inline" >
                <el-form-item>
                    <el-button type="success" icon="el-icon-search" >导入数据</el-button>
                    <el-button type="success" icon="el-icon-bottom">导出数据</el-button>
                    <el-button type="primary" icon="el-icon-plus" @click="addCompany">添加企业</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div>
            <ElementTable ref="pageTable"
                          :pageColumns="pageColumns"
                          :optBtn="optBtn"
                          :optWidth=230
                          :url="url"
                          :formObject="forObject"
                          :loading="loading"
                          @optClick="optClick"
                          @btnListClick="btnListClick"
            >

            </ElementTable>
        </div>

        <SysCompanyEdit ref="refSysCompanyEdit" @page="page"></SysCompanyEdit>
    </div>

</template>

<script>
    import ElementTable from '../../../components/base/ElementTable'
    import SysCompanyEdit from './SysCompanyEdit'
    export default {
        name: "SysCompany",
        components:{
            ElementTable,
            SysCompanyEdit
        },
        mounted() {
            this.page()
        },
        data(){
            return{
                selectIds:[],
                forObject:{
                    name:undefined
                },
                url:'/api/sys_company/page',
                loading:true,
                pageColumns:[
                    {key:'name',title:'企业名称',width:200},
                    {key:'legalPerson',title:'法人',width:200},
                    {key:'creditCode',title:'统一社会信用代码',width:160},
                    {key:'companyType',title:'公司类型',width:160},
                    {key:'manageStatus',title:'经营状态',width:200},
                    {key:'createTime',title:'成立日期',width:200},
                    {key:'regCode',title:'工商注册号',width:200},
                    {key:'regAddress',title:'注册地址',width:200}
                ],
                optBtn:[
                    {icon:'el-icon-edit',name:'编辑',id:''},
                    {icon:'el-icon-delete',name:'删除',id:''},
                ],
                getPage: {},
            }
        },
        methods:{
            btnListClick(name){
                switch (name) {
                    case '新增角色':
                        this.edit()
                        break
                }
            },
            optClick(data){
               switch (data.name) {
                   case '编辑':
                       this.edit(data.obj)
                       break
                   case 'selectData':
                       let ids = []
                       if (data.obj.length==0){
                           this.selectIds=[]
                       }else {
                           data.obj.forEach(function (item,value) {
                               ids[value]=item.id
                           })
                       }
                       this.selectIds = ids
                       break
               }
            },
            page(){
                this.$refs.pageTable.page()
            },
            addCompany(){
                this.$refs.refSysCompanyEdit.open()
            },
            edit(obj){
                this.$refs.refSysCompanyEdit.open(obj)
            }
        }
    }
</script>

<style scoped>

</style>